package api.doctor;

import java.io.IOException;
import java.util.HashMap;

import org.json.JSONException;
import org.json.JSONObject;
import common.Host;
import common.Request;


/**
 * 实现帮忙医医生获取用户报告UserCase接口调用
 * @author lipeng
 *
 */
public class UserCase {
	/**
	 * 帮忙医医生端获取用户报告UserCase接口
	 * @param token
	 * @param subjectId
	 * @return
	 * @throws IOException
	 * @throws JSONException
	 */
       public static String get(String token ,String subjectId)throws IOException,JSONException{
    	  //拼接口地址
    	   String url = Host.getAddress()+"/api/usercase"+"?subjectId="+subjectId;
    	   
    	   //调用接口并返回接口结果
    	   String result = Request.get(url, null,token);
    	   return result ;
       }
       
       
       /**
        * 帮忙医医生端查看历史UserCase接口
        * @param token
        * @param userId
        * @param flag
        * @return
        * @throws IOException
        * @throws JSONException
        */
       public static String get(String token,String userId,String flag)throws IOException,JSONException {
    	   //拼接口地址
    	   String url=Host.getAddress()+"/api/usercase"+"?userId="+userId+"&flag="+flag;
    	   
    	   //调用接口并返回接口结果
    	   String result = Request.get(url,null,token);
    	   return result;		
	  }
       
       /**
        *  帮忙医医生端保存记录UserCase接口
        * @param token
        * @param SubjectID
        * @param UserID
        * @param ChiefComplaint  --主诉
        * @param CaseHistory     --以往病例
        * @param MianDesc        --初步诊断 
        * @param Judgement       --解读意见
        * @param Suggestion      --建议
        * @param ID
        * @return
        * @throws IOException
        * @throws JSONException
        */
       public static String put(String token,String SubjectID,String UserID,String ChiefComplaint,String CaseHistory,String MianDesc,String Judgement,String Suggestion,String ID)throws IOException,JSONException{
    	   //拼接口地址
    	   String url=Host.getAddress()+"/api/usercase";
    	   
    	   //给接口参数赋值
    	   JSONObject parms = new JSONObject();
    	   parms.put("SubjectID", SubjectID);
    	   parms.put("UserID", UserID);
    	   parms.put("ChiefComplaint", ChiefComplaint);
    	   parms.put("CaseHistory", CaseHistory);
    	   parms.put("MianDesc", MianDesc);
    	   parms.put("Judgement", Judgement);
    	   parms.put("Suggestion", Suggestion);
    	   parms.put("ID", ID);
    	   
    	   //调用接口并返回接口结果
    	   String result = Request.put(url, "="+parms, token);
    	   return result;
	}
       
       /**
        * 帮忙医医生端获取完整报告UserCase接口
        * @param token
        * @param studyid 
        * @param isAllReport
        * @param tType
        * @return
        * @throws IOException
        * @throws JSONException
        */
       public static String get(String token,String studyid,String isAllReport,String rType)throws IOException,JSONException{
    	   //拼接口地址
    	   String url = Host.getAddress()+"/api/usercase"+"?studyid="+studyid+"&isAllReport="+isAllReport+"&rType="+rType;
    	   
    	   //调用接口并返回接口结果
    	   String result = Request.get(url,null,token);
    	   return result;
       }         
       
       /**
       * 实现帮忙医医生端获取报告信息接口调用
       * @param SubjectID 会话ID
       * @param rType 类型
       * @param source 资源
       * @param userId 用户ID
       * @param token 调接口需要的token
       * @return 测试数据
       * @throws IOException 
       */
       public static String get(String SubjectID,String rType,String source,String userId,String token) throws IOException
       {
    	   String url = Host.getAddress()+"/api/usercase";
    	   
    	   HashMap<String, String> parms=new HashMap<>();
    	   parms.put("SubjectID", SubjectID);
    	   parms.put("rType", rType);
    	   parms.put("source", source);
    	   parms.put("userId", userId);
    	   //调用接口并返回接口结果
    	   String result = Request.get(url,parms,token);
    	   return result;
       }
}
